app.controller('brand',function($scope,$http,$ionicLoading){
	$ionicLoading.show()
	$http.get('/api/v2/categories',{
		params:{
			"offset":0,
			"limit":4
		}
	}).then(function(res){
		if(res){
			$ionicLoading.hide()
		}
		console.log(res.data)
		$scope.titles=res.data
		$scope.info=function($index){
		if($index == undefined){
			$scope.da=0
			$http.get('/api/v2/brands',{
		   params:{
			"offset":0,
			"limit":18,
			"category_id":$scope.titles[0].id
		  }
	}).then(function(res){
		if(res){
			$ionicLoading.hide()
		}
		console.log(res.data)
		$scope.zhigao=res.data
		console.log($scope.zhigao.length)
		$scope.lengths=$scope.zhigao.length
	     $scope.shows=function(){
		$http.get('/api/v2/brands',{
		   params:{
			"offset":$scope.zhigao.length,
			"limit":18,
			"category_id":$scope.titles[0].id
		  }
	}).then(function(res){
		if(res){
			$ionicLoading.hide()
		}
		console.log(res.data)
		$scope.zhigao=$scope.zhigao.concat(res.data)
	})
		}
	$scope.loadMore=function(){
		$scope.shows()
	}
   $scope.load=function(){
	console.log('aaaa')
	$scope.loadMore()
   }
	}).catch(function(err){
		$ionicLoading.show({
			duration:3000,
			template:'获取失败qqqq'
		})
	})
//	$scope.loadMore()
		
		$scope.colors=function(){
		$('.greens').eq(0).addClass('green')
		}
	}else{
			$scope.da=$index
		$scope.colors=function(){
		$('.greens').eq(0).addClass('')
		}
		$http.get('/api/v2/brands',{
		params:{
			"offset":0,
			"limit":18,
			"category_id":$scope.titles[$index].id
		}
	}).then(function(res){
		if(res){
			$ionicLoading.hide()
		}
		console.log(res.data)
		$scope.zhigao=res.data
	}).catch(function(err){
		$ionicLoading.show({
			duration:3000,
			template:'获取失败lll'
		})
	})
	$('.greens').eq($index).addClass('green').siblings().removeClass('green')
	}
	}
		$scope.info()
	}).catch(function(err){
		$ionicLoading.show({
			duration:3000,
			template:'大的获取失败'
		})
	})
	
})